<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      label-width="84px"
    >
      <el-form-item label="玻璃ID" prop="glassId">
        <el-input
          v-model="queryParams.glassId"
          placeholder="请输入玻璃ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="流程卡号" prop="cardcode">
        <el-input
          v-model="queryParams.cardcode"
          placeholder="请输入流程卡号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="条码号" prop="barcode">
        <el-input
          v-model="queryParams.barcode"
          placeholder="请输入条码号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="干扰码" prop="disturbCode">
        <el-input
          v-model="queryParams.disturbCode"
          placeholder="请输入干扰码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button
          type="success"
          icon="el-icon-upload2"
          size="mini"
          @click="handleCommit"
          v-show="tableSwitch.length == 0 && queryParams.cardcode"
          >提交</el-button
        >
      </el-form-item>
    </el-form>
    <el-table
      v-loading="loading"
      :data="tableSwitch"
      :height="'calc(100vh - 130px)'"
      border
    >
      <el-table-column label="ID" align="center" key="id" prop="id" width="100">
      </el-table-column>

      <el-table-column
        label="类型"
        align="center"
        key="type"
        prop="type"
        show-overflow-tooltip
      />
      <el-table-column
        label="格号"
        align="center"
        key="grid"
        prop="grid"
        width="80"
        show-overflow-tooltip
      />
      <el-table-column
        label="笼号"
        align="center"
        key="group"
        width="80"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          {{ scope.row.grid | longNumber }}
        </template>
      </el-table-column>
      <el-table-column
        label="宽度"
        align="center"
        key="width"
        prop="width"
        width="80"
        show-overflow-tooltip
      />

      <el-table-column
        label="高度"
        align="center"
        key="height"
        prop="height"
        width="80"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        label="识别码"
        align="center"
        key="optCodeContext"
        fit
        width="120"
      >
        <template slot-scope="scope">
          <div class="optCodeContext" @click="openInfo(scope.row)">
            {{ scope.row.optCodeContext }}
          </div>
        </template>
      </el-table-column>
      <el-table-column
        label="客户名称"
        align="center"
        key="clientName"
        prop="clientName"
        show-overflow-tooltip
      >
      </el-table-column>
      <el-table-column
        label="配片号"
        align="center"
        key="orderNumber"
        show-overflow-tooltip
        width="100"
      >
        <template slot-scope="scope">
          {{ scope.row.optGlass.orderNumber }}
        </template>
      </el-table-column>
      <el-table-column
        label="系统位置"
        align="center"
        prop="place"
        min-width="150"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.quartz_common_location"
            :value="scope.row.place"
          />
        </template>
      </el-table-column>
      <el-table-column
        label="位置"
        align="center"
        key="spareFieldStr3"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          {{ scope.row.optGlass.spareFieldStr3 }}
        </template>
      </el-table-column>
      <el-table-column
        label="生产要求"
        align="center"
        key="spareFieldStr4"
        fit
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          {{ scope.row.optGlass.spareFieldStr4 }}
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getAllGlass, addOptMaster } from "@/api/assembly/offLine";
export default {
  dicts: [
    "quartz_glass_state",
    "quartz_common_location_search",
    "quartz_common_location",
  ],
  data() {
    return {
      queryParams: {},
      tableSwitch: [],
      loading: false,
    };
  },
  methods: {
    handleCommit() {
      addOptMaster({ cardcode: this.queryParams.cardcode }).then((res) => {
        res.code == 200
          ? this.$message.success("操作成功")
          : this.$message.success("提交失败");
      });
    },
    handleQuery() {
      console.log(Object.values(this.queryParams));
      if (
        Object.values(this.queryParams).filter((item) => item != "").length == 0
      )
        return this.$message.warning("搜索条件不能为空");
      this.loading = true;
      getAllGlass(this.queryParams).then((res) => {
        this.loading = false;
        this.tableSwitch = res.data;
      });
    },
    resetQuery() {},
    InitData() {},
  },
};
</script>

<style></style>
